<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
ka-Map Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="kaOverlay.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>kaOverlay.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'kaOverlay.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaOverlay.html">kaOverlay</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**********************************************************************
 *
 * $Id: overview-summary-kaOverlay.js.html,v 1.1 2006/03/15 15:56:58 pspencer Exp $
 *
 * purpose: an Object Overlay class
 *
 * author: Lorenzo Becchi &amp; Andrea Cappugi, Piergiorgio Navone
 *
 * TODO:
 *   - many things ...
 *
 **********************************************************************
 *
 * Copyright (c) 2005, Lorenzo Becchi &amp; Andrea Cappugi 
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 **********************************************************************/</span>

<span class="reserved">function</span> kaOverlay( oKaMap )
{
    kaTool.apply( <span class="reserved">this</span>, [oKaMap] );
    <span class="reserved">this</span>.name = <span class="literal">'kaOverlay'</span>;
	
	<span class="reserved">this</span>.XMLloaded = false;
	
	<span class="reserved">this</span>.overlayLayers= new Array();

	<span class="reserved">this</span>.output;
	<span class="reserved">this</span>.sessionId=<span class="literal">""</span>;
	<span class="reserved">this</span>.topLeft;
	<span class="reserved">this</span>.imgWidth;
	<span class="reserved">this</span>.imgHeight;
	<span class="reserved">this</span>.imageMap=<span class="literal">""</span>;

    <span class="reserved">for</span> (var p in kaTool.<span class="reserved">prototype</span>)
    {
        <span class="reserved">if</span> (!kaOverlay.<span class="reserved">prototype</span>[p]) 
            kaOverlay.<span class="reserved">prototype</span>[p]= kaTool.<span class="reserved">prototype</span>[p];
    }
    


	<span class="comment">// The list of overlay points</span>
	<span class="reserved">this</span>.ovrObjects = new Array();
	
	<span class="comment">// Register for events</span>
    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_SCALE_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.scaleChanged );
    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_EXTENTS_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.reCenter );
	

	
}

<span class="comment">/**
 * Act when scale change
 */</span>
kaOverlay.<span class="reserved">prototype</span>.scaleChanged = <span class="reserved">function</span>( eventID, mapName ) {
<span class="comment">// 	if (this.ovrObjects == null) return;</span>
<span class="comment">// 	for (var i=0; i &lt; this.ovrObjects.length; i++) {</span>
<span class="comment">// 		this.ovrObjects[i].rescale();</span>
<span class="comment">// 	}</span>
<span class="comment">//	this.draw();</span>

	<span class="reserved">this</span>.reCenter();


}
kaOverlay.<span class="reserved">prototype</span>.reCenter = <span class="reserved">function</span>() {
	<span class="reserved">if</span>(getRawObject(<span class="literal">'theInsideLayer'</span>) &amp;&amp; getRawObject(<span class="literal">'imageMapLayer'</span>) &amp;&amp; getRawObject(<span class="literal">'mapCodeDiv'</span>)){
		var imageMapLayer = getRawObject(<span class="literal">'imageMapLayer'</span>);
		var mapCodeDiv = getRawObject(<span class="literal">'mapCodeDiv'</span>);

		var defaultExtents = myKaMap.getCurrentMap().defaultExtents;
		var currentExtents = myKaMap.getCurrentMap().currentExtents;
		var geoExtents = myKaMap.getGeoExtents();
	
		var insideLayerLeft = myKaMap.theInsideLayer.style.left;
		var insideLayerTop = myKaMap.theInsideLayer.style.top;
		var xOrigin = myKaMap.xOrigin;
		var yOrigin = myKaMap.yOrigin;
		
		
		var topLeft = myKaMap.geoToPix( defaultExtents[0], defaultExtents[3] );
		topLeft[0] = topLeft[0] - xOrigin;
		topLeft[1] = topLeft[1] - yOrigin;
		<span class="reserved">this</span>.topLeft = topLeft;
<span class="comment">// 		alert(topLeft[0]+"&gt;&lt;"+imageMapLayer.style.left);</span>
<span class="comment">// 		alert(topLeft[1]+"&gt;&lt;"+imageMapLayer.style.top);</span>
	
		var bottomRight = myKaMap.geoToPix( defaultExtents[2], defaultExtents[1] );
		bottomRight[0] = bottomRight[0] - xOrigin;
		bottomRight[1] = bottomRight[1] - yOrigin;
	
		var imgWidth =  bottomRight[0] - topLeft[0];
		<span class="reserved">this</span>.imgWidth = imgWidth;
		var imgHeight = bottomRight[1] - topLeft[1];
		<span class="reserved">this</span>.imgHeight = imgHeight;
		
		imageMapLayer.style.width = <span class="reserved">this</span>.imgWidth+<span class="literal">"px"</span>;
		imageMapLayer.style.height = <span class="reserved">this</span>.imgHeight+<span class="literal">"px"</span>;
		imageMapLayer.style.top = <span class="reserved">this</span>.topLeft[1]+<span class="literal">"px"</span>;
		imageMapLayer.style.left = <span class="reserved">this</span>.topLeft[0]+<span class="literal">"px"</span>;

		mapCodeDiv.style.width = <span class="reserved">this</span>.imgWidth+<span class="literal">"px"</span>;
		mapCodeDiv.style.height = <span class="reserved">this</span>.imgHeight+<span class="literal">"px"</span>;
	}
}

<span class="comment">/**
 * Load XML from the server and update the overlay.
 *
 * xml_url	URL of th XML with points to plot
 */</span>
kaOverlay.<span class="reserved">prototype</span>.loadXml = <span class="reserved">function</span>(string) {

	<span class="reserved">this</span>.output= string;
	<span class="reserved">this</span>.XMLloaded = true;	
	eval(string);
<span class="comment">//	alert(this.sessionId);</span>
	<span class="reserved">this</span>.draw();
}


kaOverlay.<span class="reserved">prototype</span>.init = <span class="reserved">function</span>(url){
	<span class="comment">//calcolo la posizione degli oggetti</span>
	var defaultExtents = myKaMap.getCurrentMap().defaultExtents;
	var currentExtents = myKaMap.getCurrentMap().currentExtents;
	var mapName = myKaMap.getCurrentMap().name;
	var geoExtents = myKaMap.getGeoExtents();

	var insideLayerLeft = myKaMap.theInsideLayer.style.left;
	var insideLayerTop = myKaMap.theInsideLayer.style.top;
	var xOrigin = myKaMap.xOrigin;
	var yOrigin = myKaMap.yOrigin;
	

	var topLeft = myKaMap.geoToPix( defaultExtents[0], defaultExtents[3] );
	topLeft[0] = topLeft[0] - xOrigin;
	topLeft[1] = topLeft[1] - yOrigin;
	<span class="reserved">this</span>.topLeft = topLeft;

	var bottomRight = myKaMap.geoToPix( defaultExtents[2], defaultExtents[1] );
	bottomRight[0] = bottomRight[0] - xOrigin;
	bottomRight[1] = bottomRight[1] - yOrigin;

	var imgWidth =  bottomRight[0] - topLeft[0];
	<span class="reserved">this</span>.imgWidth = imgWidth;
	var imgHeight = bottomRight[1] - topLeft[1];
	<span class="reserved">this</span>.imgHeight = imgHeight;

	
	<span class="comment">//Chiamo il layer</span>
	var xmlUrl = <span class="reserved">this</span>.kaMap.server+<span class="literal">"XMLOverlay/xmlgetpolygon.php"</span>;
	var stringaUrl = 
<span class="literal">"XMLOverlay/overlay.php?xmlUrl="</span>+xmlUrl+<span class="literal">"&amp;mapName="</span>+mapName+<span class="literal">"&amp;sessionId="</span>+<span class="reserved">this</span>.sessionId+<span class="literal">"&amp;imgWidth="</span>+imgWidth+<span class="literal">"&amp;imgHeight="</span>+imgHeight;
<span class="comment">// 	stringaUrl = 'XMLOverlay/overlay.php';</span>
<span class="comment">//	alert (stringaUrl);</span>

	call(stringaUrl,<span class="reserved">this</span>,<span class="reserved">this</span>.loadXml);

}


<span class="comment">/**
 * Load XML from the server and update the overlay.
 *
 * xml_url	URL of th XML with points to plot
 */</span>
kaOverlay.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>() {

	<span class="comment">// aggiungi i layer al viewport</span>
	<span class="reserved">for</span>(i=0;i&lt;<span class="reserved">this</span>.overlayLayers.length;i++){
		myKaMap.addMapLayer( <span class="reserved">this</span>.overlayLayers[i] );
		
	}
	

	<span class="comment">//disegna livello con mappa</span>

	var insideLayerDomObj = getRawObject(<span class="literal">'theInsideLayer'</span>);
	
	div = document.createElement( <span class="literal">'div'</span> );
	div.id = <span class="literal">'imageMapLayer'</span>;
	div.className = <span class="literal">'imageMapLayer'</span>;
 	div.setAttribute(<span class="literal">'style'</span>,<span class="literal">'position:absolute;z-index:100;background-color:transparent;'</span>);
    
	image = document.createElement( <span class="literal">'img'</span> );
	image.src = <span class="literal">'images/transparent_pix.png'</span>;
<span class="comment">//     image.src = 'images/tool_zoomin_1.png';</span>
	image.id = <span class="literal">'imageMapImage'</span>;
	image.setAttribute(<span class="literal">'border'</span>,<span class="literal">'0'</span>);
 	image.setAttribute(<span class="literal">'style'</span>, <span class="literal">'position:absolute;z-index:2;width:'</span>+<span class="reserved">this</span>.imgWidth+<span class="literal">'px;height:'</span>+<span class="reserved">this</span>.imgHeight+<span class="literal">'px;'</span>);
	image.setAttribute(<span class="literal">'usemap'</span>,<span class="literal">'#overlayMap'</span>);


	<span class="comment">/*
		&lt;MAP name="map1"&gt;
		&lt;Area href="index.html" shape="rect" coords="0,0,118,28" alt="home page"&gt;
		&lt;Area href="contactus.html" shape="rect" coords="118,0,184,28" alt="contact us"&gt;
		&lt;/MAP&gt;
	*/</span>

	<span class="comment">//create element</span>
	mapCodeDiv = document.createElement( <span class="literal">'div'</span> );
	mapCodeDiv.id = <span class="literal">'mapCodeDiv'</span>;
	mapCodeDiv.setAttribute(<span class="literal">'style'</span>, <span class="literal">'position:absolute;z-index:2;left:0;top:0;'</span>);

	div.appendChild( mapCodeDiv );


	div.appendChild( image );

	insideLayerDomObj.appendChild( div );
	
	<span class="reserved">this</span>.reCenter();
	
	<span class="comment">//insert image map code in the apposite div</span>

<span class="comment">// 	getRawObject('mapCodeDiv').innerHTML =  this.imageMap;</span>
 	getRawObject(<span class="literal">'mapCodeDiv'</span>).innerHTML = <span class="reserved">this</span>.output + <span class="reserved">this</span>.imageMap;
<span class="comment">//	getRawObject('mapCodeDiv').innerHTML = fakeMap;</span>

}

kaOverlay.<span class="reserved">prototype</span>.clear = <span class="reserved">function</span>(){

	<span class="reserved">this</span>.XMLloaded = false;
	<span class="reserved">this</span>.output = null;
	<span class="reserved">this</span>.sessionId= null;

	<span class="reserved">if</span>(getRawObject(<span class="literal">'theInsideLayer'</span>) &amp;&amp; getRawObject(<span class="literal">'imageMapLayer'</span>))getRawObject(<span class="literal">'theInsideLayer'</span>).removeChild(getRawObject(<span class="literal">'imageMapLayer'</span>));


	<span class="reserved">for</span>(i=0;i&lt;<span class="reserved">this</span>.overlayLayers.length;i++){
		myKaMap.removeMapLayer( <span class="reserved">this</span>.overlayLayers[i].name );
	}

	<span class="reserved">this</span>.overlayLayers= new Array();

<span class="comment">//	myKaMap.triggerEvent(KAMAP_LAYERS_CHANGED,myKaMap.currentMap);</span>
}

kaOverlay.<span class="reserved">prototype</span>.myOnClick = <span class="reserved">function</span>() {
	
	alert(<span class="literal">'testo'</span>);
}

kaOverlay.<span class="reserved">prototype</span>.showInfo = <span class="reserved">function</span>(obj) {
	
 <span class="comment">//	alert(obj.mionome);// &lt;- non funge</span>
	var string = <span class="literal">"id: "</span>+ obj.id + <span class="literal">" | alt: "</span>+ obj.alt + <span class="literal">" | title: "</span>+ obj.title;
	alert( string );
}

</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Mar 15 10:50:59 2006</div>
</body>
</html>
